#include <arpa/inet.h>

class state_t {
    //不能创建该类的实例，因此把构造函数声明为protected，只可以从继承的类中调用
    protected:
        state_t(int type):type(type)
        {

        }
    public:
        virtual ~state_t() {};
        int type;
};

class init_t : public state_t {
    public:
        enum { id = 0 };
        init_t() : state_t(id)
    {

    }
};

class running_t : public state_t {
    public : 
     enum {id = 1};
     running_t():state_t(id)
     {

     }
     unsigned count() const
     {
        return m_count;
     }
    private:
     unsigned m_count = 0;
     socket_t m_web_pabe;
    
};

class finished_t : public state_t {
    public:
    enum {id = 2;}
    finished_t(unsigned count) : state_t(id),m_count(count)
    {

    }
    unsigned count() const
    {

    }
    private:
    unsigned m_count;
}
class program_t {
    public:
        program_t():m_state(std::make_unique<init_t>())
        {

        }
    
    void counting_finished()
    {
        auto state = static_cast<running_t*>(m_state.get());
        m_state = std::make_unique<finished_t>(state->count());
    }
    private:
        std::unique_ptr<state_t> m_state;
}

